#ifndef GLOBAL_H
#define GLOBAL_H

#include <QMutex>
#include <QObject>
#include <qhash.h>

class Global : public QObject
{
    Q_OBJECT
public:
    static Global& instance();
    void add(const QString str, QObject* p);
    QObject *get(const QString str);

    QString getStr(const QString str);

    int strToSecond(const QString str);

    enum class Cmd {
        Zero,
        WeightCalibration_0,
        WeightCalibration_weight,
        WeightToZero,
        WeightToTare,
        SpeedSet,
        PhCalibration_1,
        PhCalibration_2,
        ConductivityCalibration_1,
        ConductivityCalibration_2,
        OpenSerial,
        SetGPIO,
        Emergency,
        EmergencyClear,
        Validator,
        Error,
    };
    enum class Result{
        Zero,
        Success,
        Failure,
    };


    Q_ENUM(Cmd)
    Q_ENUM(Result)

private:
    QHash<QString, QObject*> m_hashObj;
    QHash<QString, QString>  m_hashStr;
    Global();
};

#endif // GLOBAL_H
